package com.koron.tool.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.system.staff.vo.EamUser;
import com.koron.common.core.annocation.CasUser;
import com.koron.tool.bean.*;
import com.koron.tool.service.ToolUseRecordService;
import com.koron.tool.service.ToolUserFaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @Author: liaodf
 * @Date: 2021/10/21 16:58
 */
@Slf4j
@Api(tags = "工器具记录管理")
@RestController
@RequestMapping("/toolRecord")
public class ToolUseRecordController {


    @Autowired
    private ToolUseRecordService service;

    @Autowired
    private ToolUserFaceService faceService;

    /**
     * 获取工具使用记录数据
     *
     * @param user 当前用户
     * @return Resposnse对象
     * @version 1.0
     * @see Response
     */
    @ApiOperation(value = "分页查询工具使用记录数据")
    @GetMapping("/useRecordList")
    public Response<PageInfo> useRecordList(@CasUser @ApiIgnore EamUser user, ToolUseRecordQuery query) {
        return ADOConnection.runTask(user.getCurrDs(), service, "useRecordList", Response.class,query);
    }


    /**
     * 新增数据
     *
     * @param user 当前用户
     * @param bean
     * @return Resposnse对象
     * @version 1.0
     * @see Response
     */
    @ApiOperation(value = "新增工具使用记录")
    @PostMapping("/addUseRecord")
    public Response addUseRecord(@CasUser @ApiIgnore EamUser user, @RequestBody ToolUseRecordBean bean) {
        return ADOConnection.runTask(user.getCurrDs(), service, "addUseRecord", Response.class, user, bean);
    }

    /**
     * 获取工具检验记录数据
     *
     * @param user 当前用户
     * @return Resposnse对象
     * @version 1.0
     * @see Response
     */
    @ApiOperation(value = "分页查询工具检验记录数据")
    @GetMapping("/inspectionRecordList")
    public Response<PageInfo> inspectionRecordList(@CasUser @ApiIgnore EamUser user, ToolInspectionDetailQuery query) {
        return ADOConnection.runTask(user.getCurrDs(), service, "inspectionRecordList", Response.class, query);
    }

    /**
     * 获取工具报废记录数据
     *
     * @param user 当前用户
     * @return Resposnse对象
     * @version 1.0
     * @see Response
     */
    @ApiOperation(value = "分页查询工具报废记录数据")
    @GetMapping("/scrapRecordList")
    public Response<PageInfo> scrapRecordList(@CasUser @ApiIgnore EamUser user, ToolScrapQuery query) {
        return ADOConnection.runTask(user.getCurrDs(), service, "scrapRecordList", Response.class, query);
    }

    /**
     * 获取工具使用者刷脸记录数据
     *
     * @param user 当前用户
     * @return Resposnse对象
     * @version 1.0
     * @see Response
     */

    @ApiOperation(value = "分页查询工具使用者刷脸记录数据")
    @GetMapping("/ToolUserFaceList")
    public Response<PageInfo> ToolUserFaceList(@CasUser @ApiIgnore EamUser user, ToolUserFaceQuery query) {
        return ADOConnection.runTask(user.getCurrDs(), faceService, "ToolUserFaceList", Response.class, query);
    }
}
